<script setup>
import { watch, ref } from 'vue'
const totalCount = ref(100)
const msg = ref('hello')
// watch 侦听器
// 侦听一个响应式数据
watch(totalCount, (newValue, oldValue) => {
  console.log(newValue, oldValue)
})
// 支持同时侦听多个响应式数据
// [totalCount, msg] 两个任意一个改变都会触发
watch([totalCount, msg], (newValue, oldValue) => {
  console.log(newValue, oldValue)
})

</script>
<template>
  <h1> {{totalCount}}</h1>
  <h1> {{msg}}</h1>
  <button @click="msg += '~'">{{ msg }}</button>
</template>
<style></style>
